<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
    <meta name="author" content="Coderthemes">
	
	<!-- jQuery  -->
    <script type="text/javascript" src="/static/plugins/jquery/jquery-3.6.0.min.js"></script>
	
	<!-- layui  -->
	<link rel="stylesheet" href="/static/plugins/layui/2.7.6/css/layui.css" media="all" />
	<script src="/static/plugins/layui/2.7.6/layui.js" charset="utf-8"></script>
	
	<link rel="stylesheet" href="/static/admin/css/mini-ease-edit.css">
</head>
<body>

	<form class="layui-form" id="formId" method="post" action="/api/inter/tsDictionaryForModule/importForUpdate">
		<input type="hidden" name="guid" th:value="${dto.guid}">
		<div class="layui-form-item">
			<div class="layui-inline layui-col-xs4 margin_r0">
				<div>
					<label class="layui-form-label">模块名称：</label>
					<div class="layui-input-block">
						<input type="text" name="moduleName" th:value="${dto.moduleName}" class="layui-input layui-disabled" readonly >
					</div>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-col-md5">
				<label class="layui-form-label">上传EXCEL</label>
				<div class="layui-input-block">
					<input type="text" name="link" readonly="readonly" placeholder="尚未选择文件，请点击此处选择" class="layui-input" lay-verify="required">
					<script>
					layui.use(['upload','table'], function(){
						var dom = $('input[name="link"]');
						var indexOfLoading;
						layui.upload.render({
							elem: dom,
							accept: 'file',
							acceptMime: 'application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
							ext: 'xlsx',
							url: '/api/inter/tsDictionaryForModule/uploadAndReadExcelBatchImport',
							multiple: false,
							progress: function(n, elem){
								dom.val(n + '%');
								indexOfLoading = layer.load(1, {
									shade: [0.5,'#000000'] //0.1透明度的白色背景
								});
							},
							done: function(res){
								layer.close(indexOfLoading);
								if (res.code == 0) {
									layer.msg('解析成功');
									window.importTable = layui.table.render({
										elem: '#id_table_merchant_goods',
										height: 500,
										width: 1500,
										limit: 9999,
										id: dom.attr('id'),
										totalRow: true,
										cols: [ [
												{field: 'moduleTable', title: '数据表名', width: '120px', align:'center'},
												{field: 'fieldName', title: '列名', width: '120px', align:'center'},
												{field: 'fieldAlias', title: '列别名', width: '120px', align:'center'},
												{field: 'fields', title: '字段名', width: '120px', align:'center'},
												{field: 'fieldFrontTop', title: '字段显示控制', width: '120px', align:'center'},
												{field: 'fieldFrontTemplet', title: '显示类型', width: '120px', align:'center'},
												{field: 'fieldFrontType', title: '控件类型', width: '120px', align:'center'},
												{field: 'fieldMatched', title: '触发联动字段', width: '120px', align:'center'},
												{field: 'fieldSearchType', title: '待选数据类型', width: '120px', align:'center'},
												{field: 'fieldFrontSave', title: '存储来源字段', width: '120px', align:'center'},
												{field: 'fieldFrontShow', title: '下拉显示来源字段', width: '120px', align:'center'},
												{field: 'fieldFrontAlign', title: '列内容位置', width: '120px', align:'center'},
												{field: 'fieldFrontWidth', title: '列宽度', width: '120px', align:'center'},
												{field: 'fieldFrontHeight', title: '列高度', width: '120px', align:'center'},
												{field: 'fieldFrontConditions', title: '是否查询条件', width: '120px', align:'center'},
												{field: 'fieldFrontConditionsType', title: '查询条件类型', width: '120px', align:'center'},
												{field: 'fieldFrontConditionsField', title: '查询条件字段', width: '120px', align:'center'},
												{field: 'fieldFrontConditionsFixed', title: '固定查询条件', width: '120px', align:'center'},
												{field: 'fieldFrontConditionsDefault', title: '查询条件默认值', width: '120px', align:'center'},
												{field: 'fieldFrontTotal', title: '是否合计', width: '120px', align:'center'},
												{field: 'fieldDataLimit', title: '数据权限字段', width: '120px', align:'center'},
												{field: 'fieldStandard', title: '绑定全局变量', width: '120px', align:'center'},
												{field: 'fieldFrontRequired', title: '是否必填', width: '120px', align:'center'},
												{field: 'fieldFrontOrder', title: '排列顺序', width: '120px', align:'center'},
												{field: 'fieldFrontTopOrder', title: '非网格排序', width: '120px', align:'center'},
												{field: 'fieldFrontEdit', title: '是否可编辑', width: '120px', align:'center'},
												{field: 'fieldFrontHidden', title: '是否隐藏', width: '120px', align:'center'},
												{field: 'fieldFrontHiddenList', title: '查询页隐藏', width: '120px', align:'center'},
												{field: 'fieldFrontHiddenCallIn', title: '调入页隐藏', width: '120px', align:'center'},
												{field: 'fieldFrontFixed', title: '是否固定列', width: '120px', align:'center'},
												{field: 'fieldFrontImport', title: '导入模板', width: '120px', align:'center'},
												{field: 'fieldFrontTopSize', title: '表头占用列数', width: '120px', align:'center'},
												{field: 'fieldExceptEdit', title: '指定可编辑', width: '120px', align:'center'},
												{field: 'fieldPopupShow', title: '弹窗显示', width: '120px', align:'center'},
												{field: 'fieldPopupEdit', title: '弹窗可编辑', width: '120px', align:'center'},
												{field: 'fieldFrontExtend1', title: '字段对应单据路径', width: '120px', align:'center'},
												{field: 'fieldFrontExtend2', title: '扩展属性（100）', width: '120px', align:'center'},
												{field: 'fieldFrontExtend3', title: '扩展属性（200）', width: '120px', align:'center'},
												{field: 'fieldid', title: '字段序号', width: '120px', align:'center'},
												{field: 'fieldType', title: '字段类型', width: '120px', align:'center'},
												{field: 'fieldLength', title: '字段长度', width: '120px', align:'center'},
												{field: 'fieldKey', title: '是否主键', width: '120px', align:'center'},
												{field: 'fieldNull', title: '是否允许为空', width: '120px', align:'center'},
												{field: 'fieldValue', title: '字段默认值', width: '120px', align:'center'},
												{field: 'fieldFrontValue', title: '默认值', width: '120px', align:'center'},
												{field: 'guid', title: 'GUID', width: '120px', align:'center'},
												{field: 'createTime', title: '创建日期', width: '120px', align:'center'},
												{field: 'info', title: '信息', width: '120px', align:'center'}
										] ],
										data: res.data.rows
									});
								} else{//如果上传失败
									return layer.msg('上传失败');
								}
							}
						});
					});
					</script>
				</div>
			</div>
		</div>

		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"></fieldset>
		<div class="layui-form-item">
			<div class="layui-col-md1 layui-col-md-offset11">
				<div class="layui-btn-container">
					<button type="button" class="layui-btn" lay-submit lay-filter="formSubmit">保存</button>
				</div>
			</div>
		</div>
	
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			<legend>表格信息</legend>
		</fieldset>
		<div class="layui-upload">
			<div class="layui-upload-list">
				<table class="layui-table">
					<table class="layui-hide" id="id_table_merchant_goods"></table>
				</table>
			</div>
		</div>
	</form>
	<script>
	$(function () {
		layui.use(['form'], function(){
			var form = layui.form;
			
			// 表单提交，共用同一个
			form.on('submit(formSubmit)', function(data){
				data.field['rows'] = JSON.stringify(layui.table.getData('id_table_merchant_goods'));
				var indexOfLoading = layer.load(1, {
					shade: [0.5,'#000000'] //0.1透明度的白色背景
				});
				$.post(data.form.action, data.field, function(res){
					if (res.code == 0) {
						layer.msg(res.msg);
						setTimeout(function(){
							window.parent.location.reload();
						}, 1000);
					} else {
						layer.close(indexOfLoading);
						layer.msg(res.msg);
					}
				});
				return false;
			});
		});
	});
	</script>

</body>
</html>
